package com.itstyle.mytest.queue.blockingQueueTest;

import java.util.concurrent.BlockingQueue;

/**
 * @author xianguang
 * @date 2019-12-31 14:16
 */
public class Consumer implements Runnable{

    private BlockingQueue<String> blockingQueue;

    public Consumer(BlockingQueue<String> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    @Override
    public void run() {
        System.out.println("****************************************");
        while (true){
            try {
                System.out.println("#消费者");
                System.out.println("#消费："+blockingQueue.take());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
